home *** CD-ROM | disk | FTP | other *** search
/ Programmer Power Tools / Programmer Power Tools.iso / progjrn / pj_6_6.arc / 66L6.ASM < prev    next >
Assembly Source File  |  1988-08-17  |  2KB  |  64 lines

  1. ;
  2. ; *** Listing 6 ***
  3. ;
  4. ; Solution to MASM 5.0 problem with local labels in REPT blocks.
  5. ; Adrian Crum's solution.
  6. ;
  7. ; Note: this code is relatively simple, it should be easy to follow.
  8. ; Make sure that the counter, (?CNT1) is initialized only one in
  9. ; your program. Otherwise, you will receive multi-defined errors.
  10. ;
  11. DOSSEG
  12. .MODEL SMALL
  13. .CODE
  14. ;
  15. ;
  16. SYM_SUPP1    MACRO    X
  17.     ;; support macro #1 for SYMBOLS macro
  18.     ;;
  19.     jmp    ?TMPLBL&X&
  20.     ;;
  21.     ;; Note: if you're sure that these will always be short jumps,
  22.     ;; then JMP SHORT ?TMPLBL&X&
  23.     ;;
  24. ENDM
  25. SYM_SUPP2    MACRO    X
  26.     ;; Support macro #2 for SYMBOLS macro
  27.     ;;
  28.     ?TMPLBL&X&:
  29.     ;;
  30. ENDM
  31. ;
  32. SYMBOLS    MACRO
  33.     ;; This is the main macro. No calling parameters. This macro
  34.     ;; calls two other macros to generate 10 JMP instructions to
  35.     ;; 10 temporary labels and the temporary labels themselves.
  36.     ;;
  37.     REPT    10
  38.         SYM_SUPP1    %?CNT1    ;; Generate JMP instruction
  39.         SYM_SUPP2    %?CNT1    ;; Generate label
  40.         ?CNT1 = ?CNT1 + 1    ;; Increment counter
  41.     ENDM
  42.     ;;
  43.     ;; Note: you could also define the number of repeats executed
  44.     ;; by this macro by including a dummy parameter X at the
  45.     ;; beginning of the macro and changing REPT 10 to REPT &X. The
  46.     ;; correct call in that case would be SYMBOLS n, where n is
  47.     ;; the number of repetitions.
  48.     ;;
  49. ENDM
  50. ;
  51. START:
  52.     ?CNT1 = 0            ; INITIALIZE COUNTER
  53.     SYMBOLS                ; GENERATE 10 TEMP LABELS
  54.     SYMBOLS                ; GENERATE 10 MORE LABELS
  55.     REPT 3                ; GENERATE 3 MORE LABELS
  56.         SYM_SUPP1    %?CNT1
  57.         SYM_SUPP2    %?CNT1
  58.         ?CNT1 = ?CNT1 + 1
  59.     ENDM
  60. ;
  61. END    START
  62.  
  63.  
  64.